
#ifndef  RECOVERY_FS_FILE_FILELOGGEROPERATION_H
#define  RECOVERY_FS_FILE_FILELOGGEROPERATION_H


#include <string>
#include <memory>
#include "recovery/fs/file/AbstractFileOperation.h"

namespace recovery {
namespace fs {
namespace file {

class FileLogOperation : public AbstractFileOperation {
public:
    static ErrnoStatus openExist(const std::string & path, std::unique_ptr<FileLogOperation> & operation);
    static ErrnoStatus create(const std::string & path, std::unique_ptr<FileLogOperation> & operation);
    ~FileLogOperation() override ;

    ErrnoStatus append(const std::string & data, size_t & appendedBytes);
    ErrnoStatus positionedRead(const size_t offset, uint8_t * buffer, const size_t len, size_t & readBytes) const;
    ErrnoStatus sync() const;
    ErrnoStatus size(size_t & sz) const;
    ErrnoStatus remove() const ;
    ErrnoStatus truncate(size_t size = 0) ;
private:
    explicit FileLogOperation(const std::string & path);
protected:
    ErrnoStatus closeOnce() override;
};

} //end of namespace file
} //end of namespace fs
} //end of namespace recovery

#endif   /* RECOVERY_FS_FILE_FILELOGGEROPERATION_H */
